Skip to content

Refactor WordPressSite to be a struct#25387

Merged
crazytonyli merged 3 commits into
trunkfrom
task/refactor-site-enum
Jun 11, 2026
Merged

Refactor WordPressSite to be a struct#25387
crazytonyli merged 3 commits into
trunkfrom
task/refactor-site-enum

Conversation

@crazytonyli

@crazytonyli crazytonyli commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Description

I have mixed another change in this PR, which is integration Automattic/wordpress-rs#1239 and making the WpService instance support WP.com sites. That means, you can now browse custom post types by signing in with WP.com accounts and choosing atomic sites.

Fixes https://linear.app/a8c/issue/CMM-1958

@crazytonyli crazytonyli added this to the 26.8 milestone Mar 17, 2026
@dangermattic

dangermattic commented Mar 17, 2026

Copy link
Copy Markdown
Collaborator
2 Warnings
⚠️ View files have been modified, but no screenshot or video is included in the pull request. Consider adding some for clarity.
⚠️ This PR is larger than 500 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

@wpmobilebot

wpmobilebot commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

🤖 Build Failure Analysis

This build has failures. Claude has analyzed them - check the build annotations for details.

Base automatically changed from bugfix/trashed-post-loading-errors to trunk March 17, 2026 21:00
@crazytonyli crazytonyli force-pushed the task/refactor-site-enum branch 3 times, most recently from 5c8fe6c to c4d1470 Compare March 20, 2026 00:15
@wpmobilebot wpmobilebot modified the milestones: 26.8, 26.9 Mar 20, 2026
@wpmobilebot

Copy link
Copy Markdown
Contributor

Version 26.8 has now entered code-freeze, so the milestone of this PR has been updated to 26.9.

@crazytonyli crazytonyli force-pushed the task/refactor-site-enum branch from c4d1470 to b1b1500 Compare March 22, 2026 20:42
@sonarqubecloud

Copy link
Copy Markdown

@crazytonyli crazytonyli force-pushed the task/refactor-site-enum branch from b1b1500 to 9834878 Compare April 23, 2026 10:24
@wpmobilebot

wpmobilebot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number32500
VersionPR #25387
Bundle IDcom.jetpack.alpha
Commitd77081f
Installation URL1b7a83j6etdv0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

wpmobilebot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number32500
VersionPR #25387
Bundle IDorg.wordpress.alpha
Commitd77081f
Installation URL05povcboh8qvo
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@crazytonyli crazytonyli marked this pull request as ready for review April 23, 2026 21:51
@crazytonyli crazytonyli requested a review from jkmassel April 23, 2026 21:53
@crazytonyli crazytonyli force-pushed the task/refactor-site-enum branch 2 times, most recently from dbc6313 to 5637585 Compare April 24, 2026 09:34
@crazytonyli crazytonyli force-pushed the task/refactor-site-enum branch from 5637585 to 31a8555 Compare May 6, 2026 00:24
@crazytonyli crazytonyli force-pushed the task/refactor-site-enum branch from 31a8555 to 46fcc0b Compare May 13, 2026 05:36
@crazytonyli crazytonyli force-pushed the task/refactor-site-enum branch from 46fcc0b to 4d33c9b Compare May 13, 2026 11:15
@crazytonyli crazytonyli modified the milestones: 26.9, 27.0 May 19, 2026
}

public init(blog: Blog) throws {
extension WordPressSite: Hashable {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The == conformance seems like it wouldn't be correct if the flavour or URL of a site changed (which can happen if a site is prompted from WP.com simple to Atomic, for instance)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main reason for this conformance is that WordPressSite is used as a dictionary key in a few places, which probably is not a good idea. How about I look into refactoring those usages later and then remove this Hashable conformance?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me – let's just be sure not to lose track of it! 😅

return siteURL
// Check for WordPress.com account first. This means Atomic sites
// (which have both an account and application password credentials)
// resolve to `.dotCom`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for now, but it'll need to change down the road – we want atomic sites to talk directly to the site instead of going through WP.com.

The main area this matters is the editor, where the WP.com proxy actually breaks certain endpoints we need. I think it's something we'll address in the editor loading code though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. That's a behavior change, which should not happen. The related code is in the WordPressClient.init(site: WordPressSite), which I have updated in the latest commit.

The flavor property (which is not a great name...) here indicates how the site is presented in the app: atomic site can be displayed as a self-hsoted site or part of WP.com account, depending how it's signed in.

The flavor describes how a site is presented in the app, while the new
transport property decides which endpoint and credentials are used for
wp/v2 access, preferring direct site access whenever application
password credentials are available. This restores the routing behaviour
for sites that have both a WordPress.com account and an application
password, such as Atomic sites. Also rename ApiFlavor to Flavor since
the type no longer dictates API access.
@crazytonyli crazytonyli requested a review from jkmassel June 10, 2026 22:57
@crazytonyli crazytonyli added this pull request to the merge queue Jun 11, 2026
Merged via the queue into trunk with commit 9a1558d Jun 11, 2026
26 checks passed
@crazytonyli crazytonyli deleted the task/refactor-site-enum branch June 11, 2026 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants